
#include<stdio.h>
#include<stdlib.h>
#define N 10
#define M 10
typedef struct {
	int* base;
	int* top;
	int stacksize;
}SqStack;
void InitStack(SqStack* S) {
	S->base = (int*)malloc(N * sizeof(int));
	if (!S->base) {
		exit(0);
	}
	S->top = S->base;
	S->stacksize = N;
}
void Push(SqStack* S, int e) {
	if (S->top - S->base >= S->stacksize) {
		S->base = (int)realloc(S->base, (S->stacksize + M) * sizeof(int));
		if (!S->base) {
			exit(0);
		}
		S->top = S->base + S->stacksize;
		S->stacksize += M;
	}
	S->top++;
	*S->top= e;

}
int StackEmpty(SqStack* S) {
	if (S->top == S->base || S->top < S->base) {
		return 1;
	}
	else {
		return 0;
	}
}

int Pop(SqStack* S, int* e) {
	if (S->top == S->base) {
		return 1;
	}
	*e = *S->top;
	--S->top;
	return 0;

}
int main() {
	SqStack S;
	InitStack(&S);
	int A, e;
	scanf("%d", &A);
	while (A) {
		Push(&S, A % 8);
		A = A / 8;
	}
	while (!StackEmpty(&S)) {
		Pop(&S, &e);
		printf("%d", e);
	}

	return 0;
}
